package com.david.system.mapper;

import com.david.system.pojo.Entity.UserInfo;
import com.david.system.pojo.Entity.WarehouseEntity;
import com.david.system.pojo.Entity.WhType;
import com.david.system.pojo.VO.WarehouseVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WarehouseMapper {


    List<WarehouseVO> selectWhall();

    List<WarehouseVO> selectWhByType(String type, Long userId);

    @Select("select user_id from whm_wh_user where wh_id = #{whId}")
    List<Long> selectAdminIdsByWhId(Integer whId);

    @Delete("delete from whm_wh_user where wh_id = #{whId}")
    void deleteWhUserByWhId(@Param("whId") Integer whId);


    void insertWhUser(@Param("whId") Integer whId,@Param("userInfos") List<UserInfo> userInfos);

    List<WarehouseEntity> selectWhByEntity(WarehouseEntity warehouseEntity);

    @Delete("delete from whm_wh where id = #{whId}")
    void deleteWhById(Integer whId);

    @Select("select id, name from whm_wh_type")
    List<WhType> selectWhTypeAll();

    void insertWh(WarehouseEntity warehouseEntity);

    void updateWh(WarehouseEntity warehouseEntity);

    @Select("select id from whm_wh_type where name = #{type}")
    Integer selectWhTypeByName(String type);

    @Insert("insert into whm_wh_type (name, code) values (#{name}, #{code})")
    void insertWhType(WhType whType);
}
